package A01_Map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class Studentdemo5 {
    public static void main(String[] args) {
        HashMap<Student, String> hm=new HashMap<>();

        Student s1 =new Student("张三",23);
        Student s2 =new Student("1",23);
        Student s3 =new Student("22",23);
        Student s4 =new Student("ahi",23);

        hm.put(s1,"江苏");
        hm.put(s2,"浙江");
        hm.put(s3,"湖南");
        Set<Student> keys = hm.keySet();
        for(Student key:keys){
            String value = hm.get(key);
            System.out.println(key +"=" +value);
        }
        System.out.println("--------");
        Set<Map.Entry<Student,String >> entries = hm.entrySet();
        for(Map.Entry<Student,String >entry : entries){
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key +"=" +value);
        }
        System.out.println("-------------");

hm.forEach(new BiConsumer<Student, String>() {
    @Override
    public void accept(Student student, String s) {
        System.out.println(student + "=" +s);
    }
});
    }
}
